#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <unistd.h>

// int main(void)也是可以的
int main(int argc, char **argv)
{
    // 逗号运算符， 定义多个int变量。
    int tmpsum = 0, i = 0;
    printf("while{} begin:\n");
    while (i < 5)
    {
        tmpsum += i;
        printf("add number:%d, sum now:%d\n", i, tmpsum);
        i++;
    }
    printf("while finish sum = %d\n", tmpsum);

    tmpsum = 0, i = 0;
    printf("do {} while begin:\n");
    do
    {
        tmpsum += i;
        printf("add number:%d, sum now:%d\n", i, tmpsum);
        i++;
    } while (i < 5);
    printf("while finish sum = %d\n", tmpsum);

}
#if 0
int main(int argc, char **argv)
{
    int tmpval = 0, tmpcount = 0;
    while (tmpcount++, tmpcount < 10)
    {
        printf("count = %d\n", tmpcount);
        tmpval += tmpcount;
    }
    printf("finish sum = %d\n", tmpval);

    tmpval = 0, tmpcount = 0;
    do
    {
        printf("count = %d\n", tmpcount);
        tmpval += tmpcount;
    } while (tmpcount++, tmpcount < 10);
    printf("finish sum = %d\n", tmpval);

    // 因为返回类型是int，因此return 整数;
    return 1;
}
#endif